include("shared.lua")



function ENT:Initialize()

end



function ENT:Draw()

	self.Entity:DrawModel()

	end



function ENT:Think()
	
end

function Contents(um)


	local id=um:ReadLong()

	local iparent= vgui.Create("DFrame")
	iparent:SetSize(ScrW()*.9,ScrH()*.9)
	iparent:Center()
	iparent:SetVisible(true)
	iparent:SetDraggable(false)
	iparent:SetTitle("Resource RP")
	iparent.OnKeyCodePressed= function() if(input.IsKeyDown(KEY_E)) then iparent:Close() end end
	

	local tabs= vgui.Create("DPropertySheet")
	tabs:SetParent(iparent)
	tabs:SetSize(iparent:GetWide() -20, iparent:GetTall()-50)
	tabs:Center()

	local inventory=vgui.Create("DPanel")
	inventory:SetVisible(true)
	inventory:SetSize(tabs:GetWide(),tabs:GetTall()-30)
	inventory:SetPos(0,10)

	//display inventory code
	local num_lines = um:ReadLong() // Read number of lines.
	local num=1 //layoutvariable
	for i=1, num_lines do
		local key=um:ReadString()
		local value=um:ReadLong()

		if(value>0) then
			// we will use these vars to go across and the down. (parent:getwidth etc)
			local xpos=num*100-90
			local ypos=10
			num=num+1
		
			local SpawnIcon = vgui.Create("SpawnIcon",inventory) -- The Vgui Elemnt is called SpawnIcon
			SpawnIcon:SetModel(ImgVars[key]) --Simply using SetModel for the model
			SpawnIcon:SetPos(xpos, ypos)
			SpawnIcon:SetToolTip(key)

			SpawnIcon.DoClick= function(SpawnIcon,key) end
				
			SpawnIcon.OpenMenu = function() cratecontextmenu(SpawnIcon, key,id) end

			local myLabel= vgui.Create("DLabel", inventory)
			myLabel:SetText(value)
			myLabel:SetTextColor( Color( 255, 25, 25, 255 ) )
			myLabel:SizeToContents()
			myLabel:SetPos(xpos+SpawnIcon:GetWide()-myLabel:GetWide(),64+ypos)
			
		end	
		
	end 		

	//end display inventory code


	tabs:AddSheet("CrateContents", inventory, "gui/silkicons/user", false, false, "Stuffinside this crate")

	iparent:MakePopup()

	

end

usermessage.Hook("showContents", Contents) 